package com.share.exception;

import java.io.IOException;

public class ExceptionDemo2 {
	public static void main(String[] args) {
		
		ExceptionDemo2 demo = new ExceptionDemo2();
		demo.manager();

	}

	public void test(int num) throws MyException {
		if (num < 0) {
			throw new MyException("人数不可能为负数", -1);
		}
		System.out.println("登记人数" + num);
	}

	public void manager() {
		try {
			test(-1);
		} catch (MyException me) {
			System.out.println("登记失败，出错代码：" + me.getId());
			System.out.println(me.getMessage());
		}
		System.out.println("操作结束");
	}

}
